<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }

        body {
            height: 100vh;
            background: linear-gradient(#99f, #f99)
        }

        body,
        .navbar,
        .navbar ul {
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .navbar {
            position: relative;
            padding: 20px;
            background-color: #fff;
            border-radius: 50px;
        }

        .navbar input {
            width: 40px;
            height: 40px;
            opacity: 0;
            cursor: pointer;
        }

        .navbar span {
            position: absolute;
            left: 25px;
            top: calc(50% - 10px);
            width: 30px;
            height: 4px;
            border-radius: 15px;
            background-color: #999;
            /* 元素永远不会成为鼠标事件的target（目标 */
            pointer-events: none;
            transition: transform 0.3s ease-in-out, top 0.3s ease-in-out 0.3s;
        }

        .navbar span:nth-child(3) {
            top: calc(50% + 6px);
        }

        .navbar ul {
            width: 0;
            overflow: hidden;
            white-space: nowrap;
            transition: all 0.5s;
        }

        .navbar ul li {
            list-style: none;
            margin: 0 15px;
        }

        .navbar ul li a {
            text-decoration: none;
            font-size: 20px;
            font-weight: 700;
            color: #333;
        }

        .navbar ul li a:hover {
            color: #fb7299;
        }

        .navbar input:checked~ul {
            width: 350px;
        }

        .navbar input:checked~span:nth-child(2) {
            top: calc(50% - 2px);
            transform: rotate(-45deg);
            background-color: #fb7299;
            /* 先执行top再执行transform */
            transition: top 0.3s ease-in-out, transform 0.3s ease-in-out 0.3;
        }

        .navbar input:checked~span:nth-child(3) {
            top: calc(50% - 2px);
            transform: rotate(45deg);
            background-color: #fb7299;
            transition: top 0.3s ease-in-out, transform 0.3s ease-in-out 0.3;
        }
    </style>
</head>

<body>
    <div class="navbar">
        <input type="checkbox" name="" id="">
        <span></span>
        <span></span>
        <ul>
            <li><a href="javascript:void(0)">点赞</a></li>
            <li><a href="javascript:void(0)">投币</a></li>
            <li><a href="javascript:void(0)">收藏</a></li>
            <li><a href="javascript:void(0)">关注</a></li>
            <li><a href="javascript:void(0)">分享</a></li>
        </ul>
    </div>
</body>

</html>